using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Hanoi
{
    public class FormDiskNumber : Hanoi.FormOptions
    {
        private Label lblNumberOfDisks;
        private ComboBox cbDisks;
        private PictureBox pbDisk;
        private System.ComponentModel.IContainer components = null;


        private Form _caller;
        private Panel pnControls;
        private Hanoi.Logic.Profiles.CustomProfile _cp;
        public FormDiskNumber(Form caller, Hanoi.Logic.Profiles.CustomProfile cp)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();
            base.CenterPanel(this.pnControls);

            dcui = new Hanoi.Ui.DisksConfigUi(pbDisk.Width, pbDisk.Height);
            cbDisks.Focus();
            cbDisks.SelectedIndex = 3;
            _caller = caller;
            _cp = new Hanoi.Logic.Profiles.CustomProfile();
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.lblNumberOfDisks = new System.Windows.Forms.Label();
            this.cbDisks = new System.Windows.Forms.ComboBox();
            this.pbDisk = new System.Windows.Forms.PictureBox();
            this.pnControls = new System.Windows.Forms.Panel();
            // 
            // mnuPrevious
            // 
            this.mnuPrevious.Click += new System.EventHandler(this.mnuPrevious_Click);
            // 
            // mnuNext
            // 
            this.mnuNext.Click += new System.EventHandler(this.mnuNext_Click);
            // 
            // pnOptions
            // 
            this.pnOptions.Controls.Add(this.pnControls);
            // 
            // lblInfo
            // 
            this.lblInfo.Font = new System.Drawing.Font("Nina", 8F, System.Drawing.FontStyle.Regular);
            this.lblInfo.Text = "The more disks, the more expertise you need. It grows exponentially, in powers of" +
                " two.";
            // 
            // lblNumberOfDisks
            // 
            this.lblNumberOfDisks.Font = new System.Drawing.Font("Nina", 10F, System.Drawing.FontStyle.Regular);
            this.lblNumberOfDisks.Location = new System.Drawing.Point(66, 1);
            this.lblNumberOfDisks.Size = new System.Drawing.Size(96, 25);
            this.lblNumberOfDisks.Text = "Number of Disks";
            // 
            // cbDisks
            // 
            this.cbDisks.DisplayMember = "4";
            this.cbDisks.Font = new System.Drawing.Font("Nina", 10F, System.Drawing.FontStyle.Regular);
            this.cbDisks.Items.Add("1");
            this.cbDisks.Items.Add("2");
            this.cbDisks.Items.Add("3");
            this.cbDisks.Items.Add("4");
            this.cbDisks.Items.Add("5");
            this.cbDisks.Items.Add("6");
            this.cbDisks.Items.Add("7");
            this.cbDisks.Items.Add("8");
            this.cbDisks.Location = new System.Drawing.Point(66, 29);
            this.cbDisks.Size = new System.Drawing.Size(96, 23);
            this.cbDisks.ValueMember = "4";
            this.cbDisks.SelectedIndexChanged += new System.EventHandler(this.cbDisks_SelectedIndexChanged);
            // 
            // pbDisk
            // 
            this.pbDisk.Location = new System.Drawing.Point(0, 0);
            this.pbDisk.Size = new System.Drawing.Size(60, 80);
            // 
            // pnControls
            // 
            this.pnControls.Controls.Add(this.cbDisks);
            this.pnControls.Controls.Add(this.lblNumberOfDisks);
            this.pnControls.Controls.Add(this.pbDisk);
            this.pnControls.Location = new System.Drawing.Point(6, 23);
            this.pnControls.Size = new System.Drawing.Size(164, 80);
            // 
            // FormDiskNumber
            // 
            this.ClientSize = new System.Drawing.Size(176, 180);
            this.Text = "Number of Disks";

        }
        #endregion
        Hanoi.Ui.DisksConfigUi dcui = null;


        private void mnuNext_Click(object sender, EventArgs e)
        {
            _cp.Size = int.Parse(cbDisks.SelectedItem.ToString());
            (new FormColumns(_caller, _cp, this)).Show();
            this.Hide();
        }

        private void cbDisks_SelectedIndexChanged(object sender, EventArgs e)
        {
            int diskNo = cbDisks.SelectedIndex + 1;
            dcui.Refresh(diskNo);
            pbDisk.Image = dcui.GetImage();
        }

        private void mnuPrevious_Click(object sender, EventArgs e)
        {
            _caller.BringToFront();
            _caller.Visible = true;
            _caller.Show();
            this.Dispose();
        }
    }
}
